/**
 * 0078
 *  
 * @Author : roryrywang
 * @DateTime : 2024/8/15 23:35
 */

#include "iostream"
#include "vector"

using namespace std;

class Solution {
public:
    vector<int> tmp;
    vector<vector<int>> res;

    void dfs(vector<int> &nums, int x) {
        res.push_back(tmp);
        for (int i = x; i < nums.size(); ++i) {
            tmp.push_back(nums[i]);
            dfs(nums, i + 1);
            tmp.pop_back();
        }
    }

    vector<vector<int>> subsets(vector<int> &nums) {
        dfs(nums, 0);
        return res;
    }
};

//class Solution {
//public:
//    vector<vector<int>> res;
//    vector<int> store;
//
//    void dfs(int x, vector<int> &nums) {
//        if (x == nums.size()) {
//            res.push_back(store);
//            return;
//        }
//        dfs(x + 1, nums);
//        store.push_back(nums[x]);
//        dfs(x + 1, nums);
//        store.pop_back();
//    }
//
//    vector<vector<int>> subsets(vector<int> &nums) {
//        dfs(0, nums);
//        return res;
//    }
//};


int main() {
    Solution sl;
    vector<int> nums = {1, 2, 3};
    vector<vector<int>> res = sl.subsets(nums);
    for (int i = 0; i < res.size(); ++i) {
        for (int j = 0; j < res[i].size(); ++j) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    return 0;
}